package No0074_search_a_2d_matrix

import "fmt"

func searchMatrix(matrix [][]int, target int) bool {
	a := len(matrix)
	b := len(matrix[0])
	for i := 0; i < a; i++ {
		row := matrix[i]
		if target >= row[0] && target <= row[b-1] {
			for j := 0; j < b; j++ {
				if target == row[j] {
					return true
				}
			}
		}
	}
	return false
}

func Test() {
	matrix := [][]int{{1, 3, 5, 7}, {10, 11, 16, 20}, {23, 30, 34, 60}}
	target := 3
	r := searchMatrix(matrix, target)
	fmt.Println(r)
}
